<template>
  <div>
    <div class="wrap">
      <van-address-edit
        :address-info="this.$route.params.item"
        :area-list="areaList"
        show-postal
        show-delete
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
      />
    </div>
  </div>
</template>
<script>
import { areaList } from "@vant/area-data";

export default {
  data() {
    return {
      areaList,
    };
  },
  methods: {
    onSave(content) {
      content.address =
        content.country +
        content.province +
        content.city +
        content.county +
        content.addressDetail;
      this.$store.commit("address/editAddress", [
        this.$route.params.index,
        content,
      ]);
      this.$router.push({ name: "user" });
    },
    onDelete() {
      this.$store.commit("address/removeAddress", this.$route.params.index);
      this.$router.push({ name: "user" });
    },
  },
};
</script>
<style lang="scss" scoped></style>
